<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>组件</title>
  <script src="./js/react.development.js"></script>
  <script src="./js/react-dom.development.js"></script>
  <script src="./js/babel.min.js"></script>
  <style>
    header {
      height: 100px;
      background: #aef;
    }

    main {
      height: 400px;
      background: #cea;
    }

    footer {
      height: 100px;
      background: #fcb;
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script type="text/babel">
    //声明一个类
    class Top extends React.Component {
      //必须要声明一个方法 render
      render() {
        return <header></header>;
      }
    }
    //一定要注意大小写 
    class Content extends React.Component {
      render() {
        return <main></main>;
      }
    }

    class Bottom extends React.Component {
      render() {
        return <footer></footer>;
      }
    }

    //创建虚拟 DOM 对象  
    // <Top /> => 寻找与 Top 同名的类, 然后通过该类实例化对象, 实例化对象调用 render 方法, 返回虚拟 DOM, 再进行渲染
    class App extends React.Component {
      render() {
        return <div>
          <Top />
          <Content />
          <Bottom />
        </div>;
      }
    }

    //渲染
    ReactDOM.render(<App />, document.querySelector('#root'))
  </script>
</body>

</html>